Dynamic core selection for heterogeneous multi-core systems

ABSTRACT

Example methods and apparatus to facilitate dynamic core selection are disclosed. An example apparatus includes a first processor core of a first type; a second processor core of a second type different from the first type; and software to: access a user-supplied hint indicative of a user preference to execute program code on the first processor core, the user-supplied hint including a user-defined attribute of the program code; monitor performance of the program code on the first processor core; determine, based on the user-defined attribute of the program code, a predicted performance of the program code on the second processor core is better than the performance of the program code on the first processor core; and ignore the user preference by migrating the program code from the first processor core for execution on the second processor core.

CROSS-REFERENCE TO RELATED APPLICATIONS

This patent arises from a continuation of U.S. patent application Ser.No. 16/508,916, entitled “Dynamic Core Selection for HeterogenousMulti-Core Systems,” which was filed on Jul. 11, 2019, which is acontinuation of U.S. patent application Ser. No. 14/986,678 (now U.S.Pat. No. 10,534,424), entitled “Dynamic Core Selection for HeterogenousMulti-Core Systems,” which was filed on Jan. 2, 2016, which is acontinued of U.S. patent application Ser. No. 14/169,955 (now U.S. Pat.No. 9,501,135), entitled “Dynamic Core Selection for HeterogenousMulti-Core Systems,” which was filed on Jan. 13, 2014, which is acontinuation of U.S. patent application Ser. No. 13/046,031 (now U.S.Pat. No. 8,683,243), entitled “Dynamic Core Selection for HeterogenousMulti-Core Systems,” which was filed on Mar. 11, 2011. U.S. patentapplication Ser. No. 16/508,916, U.S. patent application Ser. No.14/986,678, U.S. patent application Ser. No. 14/169,955, and U.S. patentapplication Ser. No. 13/046,031 are hereby incorporated herein byreference in their entireties. Priority to U.S. patent application Ser.No. 16/508,916, U.S. patent application Ser. No. 14/986,678, U.S. patentapplication Ser. No. 14/169,955, and U.S. patent application Ser. No.13/046,031 is hereby claimed.

FIELD

This invention relates to the field of processors and, in particular, tooptimizing power and performance efficiency.

BACKGROUND

Advances in semiconductor processing and logic design have permitted anincrease in the amount of logic that may be present on integratedcircuit devices. As a result, computer system configurations haveevolved from a single or multiple integrated circuits in a system tomultiple cores, multiple hardware threads, and multiple logicalprocessors present on individual integrated circuits. A processor orintegrated circuit typically comprises a single physical processor die,where the processor die may include any number of cores, hardwarethreads, or logical processors.

The ever increasing number of processing elements—cores, hardwarethreads, and logical processors—on integrated circuits enables moretasks to be accomplished in parallel. However, processors that employall out-of-order cores may lead to power inefficiencies and/orperformance inefficiencies under some circumstances. As a result, somehardware-software co-designed systems have been developed to confrontthe power-performance efficiency problem. In that system, a wide, simplein-order processor may be utilized, while software optimizes andschedules programs to run on the in-order hardware efficiently.

Yet, hardware-software co-designed systems are typically associated withtwo adverse impacts: (1) translation and/or optimization of codeutilizing a binary translator may slow down some applications with shortrunning tasks and small response-time constraints (a binary translationglass jaw); and (2) an in-order processor may not perform well for somestyles of programs that are better suited for parallel execution (anin-order glass jaw).

BRIEF DESCRIPTION OF THE DRAWINGS

The present invention is illustrated by way of example and not intendedto be limited by the figures of the accompanying drawings.

FIG. 1 illustrates an embodiment of a processor including twoheterogeneous cores.

FIG. 2 illustrates an embodiment of a processor including a native core,a software-managed core, and a code distribution module.

FIG. 3 illustrates an embodiment of a processor for distributing codeamong cores to achieve maximum performance and maximum power savings.

FIG. 4 illustrates an embodiment of a flow diagram for a method ofdistributing code among an out-of-order core and an in-order core toachieve maximum performance and power savings.

FIG. 5 illustrates another embodiment of a flow diagram for a method ofdistributing code among an out-of-order core and an in-order core toachieve maximum performance and power savings.

FIG. 6 illustrates core switch operations and overhead according to anembodiment of the present invention.

DETAILED DESCRIPTION OF THE DRAWINGS

A heterogeneous computing strategy is to integrate a number of cores,wherein each core is efficient at executing certain code but inefficientat executing certain other code. The runtime software (SW) and hardware(HW) collaboratively partition the input program into code segmentssuitable for different cores, and execute each of them on the mostappropriate core, while putting the other cores in low power state, toachieve high performance with low power and energy consumption. Oneexample of such a system consists of at least one wide-in-order core andat least one narrow out-of-order core, and according to embodiments ofthe present invention, this heterogeneous system can achieve improvedout-of-order core performance while consuming a fraction of energy andpower. A major challenge for this type of computing system is toidentify program behavior changes quickly and switch to the appropriatecore efficiently at runtime. Embodiments of the present invention useruntime software and/or hardware to automatically switch execution ofdifferent code segments in the same program to the most appropriatecore, and significantly speed up performance of single threadedprograms.

In the following description, numerous specific details are set forthsuch as examples of specific types of processor cores, specificprocessor configurations, specific hot code region identificationalgorithms, specific structures for storing translated/optimized code,specific division of tasks between hardware/software, specific processorunits/logic, etc. in order to provide a thorough understanding of thepresent invention. It will be apparent, however, to one skilled in theart that these specific details need not be employed to practice thepresent invention. In other instances, well known components or methods,such as specific and alternative processor architecture, specific logiccircuits/code for described algorithms, specific code implementations,specific binary translation details, and other specific operationaldetails of microprocessors haven't been described in detail in order toavoid unnecessarily obscuring the present invention.

In one embodiment, the method and apparatus described herein are forimplementing a native core with a software-managed core to achievemaximum performance and power savings. Specifically, the collaborationbetween cores is discussed primarily in reference to an out-of-ordercore and an in-order, co-designed core. Yet, the apparatus' and methodsdescribed herein are not so limited, as they may be implemented in anydistribution of code between heterogeneous cores. For example, the codedistribution methods and apparatus' described herein may be utilizedwith two out-of-order cores that implement unique Instruction SetArchitectures (ISAs). Furthermore, the collaboration between such coresis often discussed as split between hardware mechanisms andcode/software. However, any blend or exclusive use of hardware,software, and/or firmware may be utilized to implement the methods andapparatus' described below.

Referring to FIG. 1 , an embodiment of a processor including multiplecores is illustrated. Processor 100 includes any processor, such as amicroprocessor, an embedded processor, a digital signal processor (DSP),a network processor, or other device to execute code. Processor 100, inone embodiment, includes at least two cores—core 101 and 102—ofdifferent types. However, processor 100 may include any number ofprocessing elements.

In one embodiment, a processing element refers to a thread unit, athread slot, a process unit, a context, a logical processor, a hardwarethread, a core, and/or any other element, which is capable of holding astate for a processor, such as an execution state or architecturalstate. In other words, a processing element, in one embodiment, refersto any hardware capable of being independently associated with code,such as a software thread, operating system, application, or other code.A physical processor typically refers to an integrated circuit, whichpotentially includes any number of other processing elements, such ascores or hardware threads.

A core often refers to logic located on an integrated circuit capable ofmaintaining an independent architectural state wherein eachindependently maintained architectural state is associated with at leastsome dedicated execution resources. In contrast to cores, a hardwarethread typically refers to any logic located on an integrated circuitcapable of maintaining an independent architectural state wherein theindependently maintained architectural states share access to executionresources. As can be seen, when certain resources are shared and othersare dedicated to an architectural state, the line between thenomenclature of a hardware thread and core overlaps. Yet often, a coreand a hardware thread are viewed by an operating system as individuallogical processors, where the operating system is able to individuallyschedule operations on each logical processor.

Physical processor 100, as illustrated in FIG. 1 , includes two cores,core 101 and 102. Here, core 101 and 102 are considered heterogeneouscores, i.e. cores with different configurations, functional units,and/or logic. In one embodiment, core 101 includes an out-of-orderprocessor core, while core 102 includes an in-order processor core.However, cores 101 and 102 may be individually selected from any type ofcore. Yet to further the discussion, the functional units illustrated inFIG. 1 are described in further detail below.

As depicted, core 101 includes two hardware threads 101 a and 101 b,which may also be referred to as hardware thread slots 101 a and 101 b.In contrast, core 102 includes one hardware thread 102 a. Therefore,software entities, such as an operating system, in one embodimentpotentially view processor 100 as three separate processors, i.e. threelogical processors or processing elements capable of executing threesoftware threads concurrently. Alternatively, a software entity may onlyview processor 100 as having two separate processors—thread slots 101 aand 101 b—while the described code distribution mechanisms manageexecution of code on core 102.

A first thread is associated with architecture state registers 101 a, asecond thread is associated with architecture state registers 101 b, anda third thread may be associated with architecture state registers 102a. As illustrated, architecture state registers 101 a are replicated inarchitecture state registers 101 b, so individual architecturestates/contexts are capable of being stored for logical processor 101 aand logical processor 101 b. Architecture state registers 102 a may bethe same as registers 101 a, 101 b. Or registers 102 a may instead beunique to the architecture of core 102. In core 101, other smallerresources, such as instruction pointers and renaming logic in renameallocator logic 130 may also be replicated for threads 101 a and 101 b.Some resources, such as re-order buffers in reorder/retirement unit 135,instruction-translation buffer (ITLB) 120, load/store buffers, andqueues may be shared through partitioning. Other resources, such asgeneral purpose internal registers, page-table base register, low-leveldata-cache and data-TLB 150, execution unit(s) 140, and portions ofout-of-order unit 135 are potentially fully shared.

Processor 100 often includes other resources, which may be fully shared,shared through partitioning, or dedicated by/to processing elements. InFIG. 1 , an embodiment of a purely exemplary processor with illustrativelogical units/resources of a processor is illustrated. Note that aprocessor may include, or omit, any of these functional units, as wellas include any other known functional units, logic, or firmware notdepicted. As illustrated, core 101 is illustrated as a simplifiedout-of-order (OOO) processor core. The OOO core includes a branch targetbuffer (BTB) 120 to predict branches to be executed/taken and aninstruction-translation buffer (I-TLB) 120 to store address translationentries for instructions.

Core 101 further includes decode module 125 coupled to fetch unit 120 todecode fetched elements. Fetch logic, in one embodiment, includesindividual sequencers associated with thread slots 101 a, 101 b,respectively. Usually core 101 is associated with a first InstructionSet Architecture (ISA), which defines/specifies instructions executableon processor 100. Here, often machine code instructions that are part ofthe first ISA include a portion of the instruction (referred to as anopcode), which references/specifies an instruction or operation to beperformed. Decode logic 125 includes circuitry that recognizes theseinstructions from their opcodes and passes the decoded instructions onin the pipeline for processing as defined by the first ISA.

In one example, allocator and renamer block 130 includes an allocator toreserve resources, such as register files to store instructionprocessing results. However, threads 101 a and 101 b are potentiallycapable of out-of-order execution, where allocator and renamer block 130also reserves other resources, such as reorder buffers to trackinstruction status. Unit 130 may also include a register renamer torename program/instruction reference registers to other registersinternal to processor 100. Reorder/retirement unit 135 includescomponents, such as the reorder buffers mentioned above, load buffers,and store buffers, to support out-of-order execution and later in-orderretirement of instructions executed out-of-order.

Scheduler and execution unit(s) block 140, in one embodiment, includes ascheduler unit to schedule instructions/operation on execution units.For example, a floating point instruction is scheduled on a port of anexecution unit that has an available floating point execution unit.Register files associated with the execution units are also included tostore information instruction processing results. Exemplary executionunits include a floating point execution unit, an integer executionunit, a jump execution unit, a load execution unit, a store executionunit, and other known execution units.

Lower level data cache and data address translation lookup/side buffer(D-TLB) 150 are coupled to execution unit(s) 140. The data cache is tostore recently used/operated on elements, such as data operands, whichare potentially held in memory coherency states. The D-TLB is to storerecent virtual/linear to physical address translations. As a specificexample, a processor may include a page table structure to breakphysical memory into a plurality of virtual pages.

As stated above, in one embodiment, core 102 includes an in-order,co-designed core. As a result, FIG. 1 illustrates a simplified pipelineof an in-order core. This pipeline includes fetch unit 121, decode unit126, execution unit(s) 141, and a lower-level data cache 151. Theseunits may work in a similar manner to the corresponding units in core101. Yet, in an in-order core, the instructions/operations are executedin program order, instead of potential out-of-order execution as in core101. In one example, out-of-order core 101 is referred to as the nativecore, while the in-order core 102 is referred to as a co-designed core.Alternatively, in-order core 102 is the native core and out-of-ordercore 101 is the co-designed core.

Here, cores 101 and 102 share access to higher-level or further-outcache 110, which is to cache recently fetched elements. Note thathigher-level or further-out refers to cache levels increasing or gettingfurther way from the execution unit(s). In one embodiment, higher-levelcache 110 is a last-level data cache—last cache in the memory hierarchyon processor 100—such as a second or third level data cache. However,higher level cache 110 is not so limited, as it may be associated withor include an instruction cache. A trace cache—a type of instructioncache—instead may be coupled after decoder 125 to store recently decodedtraces.

In the depicted configuration, processor 100 also includes linkinterface module 105 to communicate with devices external to processor100, such as system memory 175, a chipset, a northbridge, or otherintegrated circuit (including single integrated circuit implementationssuch as a “system on a chip” (SOC)). Memory 175 may be dedicated toprocessor 100 or shared with other devices in a system. Common examplesof types of memory 175 include dynamic random access memory (DRAM),static RAM (SRAM), non-volatile memory (NV memory), and other knownstorage devices.

In one embodiment, code is distributed between core 101 and 102 based onmaximizing performance and power. For example, code regions areidentified to perform better on one of the two cores 101, 102. As aresult, when one of such code regions is encountered/detected, that codesection is distributed to the appropriate core. Identification of suchregions may be done statically (before execution of the code, such asthrough program profile analysis) or dynamically (during execution ofthe code) by hardware, software, or a combination thereof.

In one illustrative example of a dynamic approach, one processor core,such as core 101, may be selected as a default core to execute codebased on its performance, power-savings, native ISA, any other knownprocessing consideration, or a combination thereof. Then, regions of thedefault code that execute poorly on core 101, or would execute better oncore 102, are identified. Upon subsequently encountering thoseidentified code sections, they are distributed to core 102 forexecution. Note that execution of those regions on core 102 may includespeculative, run-ahead execution to warm-up core 101, serial executionof those regions on core 102 with execution of other regions on core 101that depend on results from those regions, or parallel, concurrentexecution of those regions with execution of other code on core 102.

In an example of a static approach, a compiler or user may identifysections of code, such as with instructions or demarcations, whichexecute better on one core or the other. Here, core 101 executes codeuntil such an instruction is encountered. Either in response tomonitoring from core 102 or by sole initiative (triggering) of core 102,the identified code section is then executed on core 102 based on theencountered instruction.

Whether identification of code sections to run better on one core oranother is done dynamically or statically, in some embodiments, nativecode is translated and/or optimized to be run on another core. Forexample, assume core 101 includes decode logic 125 that recognizes afirst ISA type, and core 102 includes decode logic 126 that recognizes asecond ISA type. In this case, if a code region of the first ISA type isto be executed on core 102, then the code region is translated to thesecond ISA type to be executed on core 102. Note that translationbetween ISA types is purely illustrative. Instead, out-of-orderoptimized code to be executed on core 101 may be re-optimized forexecution of in-order core 102. In this scenario, core 102 may includethe same, or a subset of, the same ISA as core 101. Yet, optimizationsare performed on the code to ensure it runs more efficiently on asimple, wide in-order core.

The collaboration between core 101 and core 102 to distribute codeefficiently may be implemented in hardware, firmware, software, or acombination thereof. The example above regarding a dynamic approach toidentifying code regions is further examined to illustrate exemplaryembodiments of collaboration mechanisms. In the example, program code,in a native format, is optimized to execute on out-of-order core 101.During execution of a code region or the program code, monitor hardwareassociated with core 101 and/or core 102 may be utilized to determinethe performance associated with core 101's execution of the code region.Alternatively, code, such as software, OS code, micro-code, or othercode, may be executed on core 102, to determine/monitor the performanceof core 101 in executing the code region. If it's determined that thecode region would be better executed on core 102, then hardware,software, firmware, or a combination thereof may be utilized totranslate and/or optimize the code region to be executed on core 102.

As a result, when core 101 encounters the code region again—aninstruction pointer references the code region, an identifierinstruction to identify the code region is fetched or decoded, oranother way of identifying a code region is detected—then thetranslated/optimized version of the code region is executed on core 102.In one embodiment, during execution of the code region on core 102, core101 may concurrently execute other code regions to increase overallprogram execution performance. Note that concurrent or parallelexecution may include execution of separate software threads on cores101, 102 as well.

In contrast, threads may be pipelined on cores 101, 102. As an exampleof this scenario, assume each of the two software threads includesmultiple stages of code (hot, cold, etc). Here, cold code from a firstthread may be executed on core 101, and when a hot region isencountered, a translated hot region is executed on core 102. Duringexecution of the translated hot region of code on core 102, cold codefrom the second thread may be executed on core 101. On core 102, whenexecution of the first translated hot code completes, execution ofanother hot region from the second software thread may then be started.As can be seen from this example, the stages of code may be interleavedon each core resulting in a pipelined type of execution. In anotherembodiment, code may be executed sequentially with respect to the twocores, such as a code region on core 101, the identified code region oncore 102, and then subsequently another code region on core 101.

In addition, even when a code region is initially identified forexecution on core 102, the performance of that execution may also bemonitored. The performance on both cores may then be taken into accountin determining which core is best suited to execute the code region toachieve maximum performance and power savings. For example, if a coderegion is identified to be executed as translated code on core 102, butthe performance on core 102 is below the performance on core 101 (or theperformance gain on core 102 doesn't outweigh the power savings ofexecution on core 201), then the code may be re-distributed to core 101upon subsequent encounters.

FIG. 1 illustrates an abstracted, logical view of an exemplary processorwith a representation of different modules, units, and/or logic.However, note that a processor utilizing the methods and apparatus'described herein need not include the illustrated units. And, theprocessor may omit some or all of the units shown. Furthermore, amajority of the discussion above has been in reference to anout-of-order processor core and an in-order processor core. However, asaforementioned, the two processor cores may be any version ofheterogeneous cores, such as a native core and a software managed core.In addition, FIG. 1 only depicts two cores; yet, a processor may includeany number of cores, such as multiple cores of the same type, as well asmore than two cores that each differ in type.

FIG. 1 also illustrates an embodiment of processor that is coupled in apoint-to-point fashion with an interface to an external memorycontroller (controller hub 170). However, many current processors havebegun including an on-processor memory interface module—an on-chipmodule—with a ring configuration to interconnect multiple cores, as wellas shared caches and other interfaces. Although not illustrated,processor 100, in one embodiment, includes a ring interconnect couplingcore, cache, and memory controller components.

Here, caching agents are utilized to manage a slice of a physicallydistributed cache. As an example, each cache component is to manage aslice of a cache for a collocated core—a core the cache agent isassociated with for purpose of managing the distributed slice of thecache. Much like cache agents handle traffic on a ring interconnect andinterface with cache slices, core agents/components are to handletraffic and interface with cores. Additionally, the ring interconnectmay couple Memory Controller Interface Logic (MCIL) and/or othercontrollers to interface with other modules, such memory and/or agraphics processor.

Referring to FIG. 2 an embodiment of a code distribution module todistribute code among two cores is illustrated. In one embodiment, cores201, 202 are heterogeneous cores. For example, core 201 is anout-of-order (OOO) core adapted to execute code out of original programorder, and core 202 is an in-order (or serial core) adapted to executecode in program order. A non-exhaustive exemplary list of other coretypes include: a native core, a non-native core, a software managedcore, a native ISA core, a translated ISA core, a co-designed core, aspeculative execution core, and a non-speculative execution core.

In one embodiment, code distribution module 210 is to distribute codebetween core 201 and 202 based on maximizing performance and powersavings. A module as used herein may refer to hardware, software,firmware, or a combination thereof. Additionally, a module, unit, orlogic may be centralized in a core or processor, as well as distributedthroughout. For example, code distribution module 210 may includedistribution code, such as micro-code or software, held in storageassociated with core 201, core 202, processor 200, or a system includingprocessor 200. Here, the distribution code, when executed, is to performthe code distribution. In contrast, the code distribution process may bemanaged by hardware, software, firmware, or a combination thereof.

In one embodiment, code distribution module 210 is to dynamically switchexecution of program code from one core to another. Dynamicallyswitching program code is discussed in more detail below in reference toFIG. 4 and FIG. 5 . However, as an illustrative example for this sectionof discussion, program code may include any code to be executed with aprocessing element, such as binary or machine code. A hot portion ofcode may refer to a portion of code that is better suited to execute onone core over the other based on considerations, such as power,performance, heat, other known processor metric(s), or a combinationthereof. Here, assuming core 201 is a default core for native executionof the program code, then identification of a hot portion of the programcode includes determining a portion of code that is better suited to beexecuted on core 202. In the embodiment where core 201 is an OOO coreand core 202 is an in-order core, then a hot portion of code may referto a hot spot of the program code that is better suited to be executedon serial core 202, which potentially has more available resources forexecution of a highly-recurrent section. As an example, a hot portion ofcode is identified by a recurrence pattern of the portion of code, orsome other known metric, such as instruction count or cycle count. Oftena section of code with a high-recurrence and predictable latency patternmay be optimized to be executed more efficiently on an in-order core.Essentially, in this example, cold code (low-recurrence) is distributedto native, OOO core 101, while hot code (high-recurrence) is distributedto software-managed, in-order core 102.

A hot portion of code may be identified statically, dynamically, or acombination thereof. In the first case, a compiler or user may determinea section of program code is hot code. Here, a hot code identifierinstruction(s) may demarcate a section of code as hot, i.e. to beexecuted on core 202 instead of on core 101. Decode logic in core 201,in one embodiment, is adapted to decode a hot code identifierinstruction from the program code, which is to identify the hot portionof the program code. The fetch or decode of such an instruction maytrigger translation and/or execution of the hot section of code on core202. In this example, the code distribution module 210 includes thedecode logic to detect the hot code detection instruction. And module210 may also include other hardware and/or software to carry out thetranslation/optimization, as well as the execution of the hot code oncore 202. Alternatively, the hot-code section may bepre-optimized/translated for execution on core 202.

In another example, code distribution module 210 dynamically (duringexecution) identifies hot spots/regions in program code. In oneembodiment, hardware included in core 201 and/or core 202 is utilized toprofile execution of the program code on a core, such as core 201. Basedon the characteristics of the profile—power and/or performance metricsassociated with execution—a region of the program code may be identifiedas hot code. Similar to the operation of hardware, monitoring code maybe executed on one core, such as core 202, to perform themonitoring/profiling of program code being executed on the other core,such as core 201. Note that such monitoring code may be code held instorage structures within the cores, within processor 200, or held in asystem including processor 200. For example, the monitoring code may bemicrocode, or other code, held in storage structures of core 201, core202, or processor 200. And, the monitoring code may be executed bytraditional execution units, as well as other firmware or logic onprocessor 200.

As yet another example, a static identification of hot code is made as ahint. But dynamic profiling of the program code execution is able toignore the static identification of a region of code as hot; this typeof static identification is often referred to as a compiler or user hintthat dynamic profiling may take into account in determining which coreis appropriate for code distribution. Moreover, as is the nature ofdynamic profiling, identification of a region of code as hot doesn'trestrict that section of code to always being identified as hot. Forexample, assume program code is being executed on an out-of-order core201. Monitor code executing on core 202 monitors the performance levelof core 201's execution of a section of the program code. Based on theimplementation, if the performance on core 201 is determined to beenough lower than it would perform on core 202 and/or a recurrencepattern of the code section on core 201 is high-enough to be predictedto hide core transition overhead; then the code section is identified ashot. After translation and/or optimization, a translated version of thecode section is executed on core 202. Similar to the monitoring ofexecution on core 201, the execution of the translated version of codemay be monitored on core 202, such as through execution of theperformance monitoring code. If the performance is lower on core 202than on core 201, then the identification of the code section as hot maybe dynamically reversed (the section of hot code may be relabeled ascold code).

Once a section, spot, or region of codes is identified as hot, codedistribution module 210, in one embodiment, optimizes and/or translatesthe hot section of code to obtain optimized/translated hot code. In oneembodiment, translation and/or optimization code, such as binarytranslation code, is held in storage logic of core 202. As an example,the binary translation code may be part of micro-code held in core 202.The translation/optimization code, when executed, translates/optimizesthe code section for execution on core 202. In one embodiment, core 201,202 may recognize the same ISA, or a subset thereof, wheretranslation/optimization is merely translating/optimizing code toexecute more efficiently on core 202. In another embodiment, core 201,202 recognize different ISAs, where translation includes translating thecode region from one ISA recognizable by core 201 to another ISArecognizable by core 202. Although translation/optimization is discussedin reference to execution of translation/optimization code, any knownmechanism for translating/optimizing code, even through exclusivehardware, may be utilized.

In one embodiment, upon encountering an identified section of hot codewith core 201, the hot code (a translated version thereof) is executedon core 202. Any known trigger for determining when a hot code region isencountered may be utilized. A few high-level examples include:encountering/referencing an instruction address associated with the coderegion, fetching/decoding/scheduling/executing an instructionidentifying a code section as hot code,fetching/decoding/scheduling/executing an instruction indicating atranslated version of hot code is to be executed on another core, anexternal trigger from a monitor indicating a hot code region has beenencountered, etc.

As an illustrative example, code distribution module 210 includes amonitor module implemented in hardware, software, or a combinationthereof. When the monitor module identifies a hot region of code ortranslates the hot region to a translated region, the monitor moduleregisters an instruction address associated with the hot region of code.This registration may include association of the instruction addresswith a location of the translated region of code. Then, when aninstruction pointer (program counter) subsequently references theinstruction address, it's determined from the registered instructionaddress that a hot region of code has been encountered. Note that anyform of detection may be used here, such as a synchronous orasynchronous interrupt style of handling the encounter event.Additionally, hardware, micro-code, and/or firmware may be capable ofdirectly handling the encounter of a hot code section withoutinterrupt-like handling, i.e. the trigger event is not serviced by ahandler. Note that core 101 and 102 may share certain hardwarestructures, such as a mapping structure, to identify addresses that areregistered as hot code.

In response to encountering a hot code section on core 201, a translatedand/or optimized version of the hot code section is executed on core202. Despite how the hot code section is identified and encountered oncore 201, any known method for enabling execution of code on anothercore may be utilized. In one embodiment, a collaboration module isutilized to enable such execution. For example, cores 201, 202 may sharecertain hardware structures and/or include communication channels toshare information. As one example, cores 101, 102 may share a datacache, so when execution is migrated from core 201 to 202, the dataisn't physically moved, but rather is already resident in the sharedcache. Similarly, a register file, such as a shadow register file, inone embodiment, is shared between cores 201 and 202, so register states(context) doesn't have to be migrated from one core to another. As analternative, instead of sharing a register file, a high-speedinterconnect may be used to physically migrate context, or a portionthereof, from one core to another. Additionally, with infrequenttransfers software may be utilized to perform such transfers.

As one example, input values into a hot code-section are transferredfrom core 201 to core 202 to support execution of the hot-code sectionon core 202. After execution, output values are then transferred back tocore 201. In one embodiment, only identified input/output values fromcode sections are transferred, i.e. a partial context switch. Note thatsuch input values may be identified by the user (software/compiler)and/or by hardware/firmware algorithms. Here, direct access hardware maybe adapted to read input values from registers, buffers, or otherstructures in core 201 and write them to core 202. Inversely, the sameor different hardware may be utilized to read values from core 202 andwrite them to core 201. However, where identifying such values becomestoo cumbersome, an entire context switch, replication, or sharing may beperformed to provide values between cores 201 and 202.

Referring next to FIG. 3 , an embodiment of a processor for distributingcode among cores to achieve maximum performance and power savings isdepicted. As above, processor 300 includes two processor cores; each ofwhich is of a different core type. As one example, core 301 is a native,out-of-order (OOO) processor core, while core 302 is a software managed,in-order processor core. Core 301 and 302 may, but are not required to,recognize different ISA types. In fact, core 302 may recognize a subsetof core 301's ISA. Or, core 302 may include a separate ISA thatpartially overlaps core 301's ISA. As described above, a core orprocessor is often associated with an ISA—a definition of recognizedinstruction—by decode hardware/software in the core or processor.

In one embodiment, monitor module 305 is to monitor execution of nativeprogram code 325 on native, OOO core 301; through this monitoring,module 305 is to identify a hot portion/region 327 of the program code325. Monitor module may be comprised of hardware, software, or acombination thereof. In one embodiment, monitor module 305 includeshardware to monitor execution. As one example, the hardware includesmicro-architectural and/or architectural hooks, such as retirementpushout tags/counters to measure retirement pushouts, instructioncounters to count numbers of instructions, overall trace executionmeasurement logic to measure overall execution length and/or time,recurrence counters to count a number of times a code section wasexecuted, etc., to determine performance/power metrics during executionof code 325. This type of hardware may be located in any portion of anintegrated circuit/processor, such as within out-of-order core 301,within in-order core 302, and in a non-associated portion of theintegrated circuit that is not included within either OOO processor core301 or the in-order processor core 302.

In another embodiment, monitor module 305 includes software, such asmonitor code, which when executed, is to monitor execution of programcode 325 and to identify a hot region 327 of the program code 325. As anillustrative example, processor 300 includes storage structures, such asRead Only Memory (ROM) structures, programmable logic, etc, to holdcode, microcode, or machine code, when executed, causes the monitoringto occur. However, monitor code may be stored in any machine readablemedium associated with cores 301, 302. Note that use of the termexecution is not only limited to execution by traditional executionunits, but instead may refer to execution by other hardware orprogrammable logic associated with processor 300, such as execution ofmicrocode with firmware. Here, the executed monitor code may perform thesame monitoring of recurrence, power, and performance metric that ismeasureable by hardware.

As one example, the monitoring hardware and/or code tracks/determinesrecurrence patterns for code sections of the program code. As a simpleexample, a data structure associates a reference to a code section (coderegion 327), such as an instruction address, with a count of the numberof times the instruction address/code section has been executed on core301. Note that the count may be associated with an absolute count (totalcount) or a temporal count (a count over an amount of time).

In one embodiment, monitor module 305 is adapted to identify/detect ahot portion 327 of program code 325. Monitor module 305, in one example,is to measure one or more performance metric(s) for the hot portion 327of the program code 325 during execution on OOO processor core 301. Andmodule 305 is to identify the hot portion 327 of program code 325 inresponse to the performance metric(s) on the OOO processor core beingbelow a threshold. A non-exhaustive, illustrative list of examples ofperformance metrics include: instruction retirement pushout, a number ofinstructions executed, an amount of time to execute a code region, anumber of times a code regions is encountered/executed, an amount ofpower consumed during execution of a code region, an amount of timespent in different power states during execution of a code region, athermal density during execution of a code segment, etc.

Using one of the examples above, assume OOO core 301 is executingprogram code 325. Monitor code is being executed to determine a numberof times regions of program code 325 are executed on core 301. When thatcount meets or exceeds a threshold, in one embodiment, monitor module305 identifies/determines that region 327 is hot code. If a thresholdvalue of three is used, then when monitor code executing on core 302detects hot region 327 being re-executed a third time on core 301,region 327 is identified as a hot region of code. The specific exampleof determining a recurrence pattern may be extrapolated to see that asimilar process—count, compare against a threshold, and identify—may beemployed for any measured performance metric. Furthermore, determining aperformance metric is not limited to simple counts, but may include anyknown algorithm for determining execution or power savings performancein a core, processor, or computer system.

However, identifying hot region 327 within program code 325 is notlimited to dynamic performance monitoring. Instead, compiler or staticprogram analysis may be utilized to determine code sections that arelikely to be better suited for execution on in-order core 302. Forexample, assume program analysis reveals that hot region 327 is likelyto be re-executed a number of times. In response to this discovery, acompiler or user may insert instructions or demarcations identifying asection of code as hot code. Therefore, when decoders of core 301encounter such instructions, they recognize that region 327 is hot codethat is to be executed on core 302. Note that in some embodiments, usersmay identify such regions of code based on their knowledge of a programwithout in-depth program analysis.

In one embodiment, in response to identifying region 327 as hot, code327 is optimized or translated by optimization/translation module 310 toobtain optimized hot code 304. Similar to operation of monitor module305, optimization module 310 may be implemented in hardware, software,firmware, or a combination thereof. For example, translation and/oroptimization code may be stored in structures associated with core 302,core 301, or processor 300. To illustrate, binary translation code isstored in firmware associated with core 302. And the binary translationcode is executed to translate hot region 327 from a native format forcore 301 to a format for core 302. Note that translation may be betweenISAs or other formats, while optimization may include any known methodfor optimizing code for execution, such as known techniques foroptimizing code from parallel execution on OOO core 301 to serialexecution on core 302, as well as the inverse.

However, use of binary translation code in firmware is purelyillustrative, as any translation code or optimization code may be heldanywhere in a computer system, such as microcode in core 302 or regularprogram code in a system memory. And, the optimization code may beexecuted in any manner to translate or optimize hot region 327 to obtainoptimized hot code 304. In fact, any known methods or apparatus' fortranslating or optimizing code for a core, such as the methods andapparatus' known for translating code in current software managedprocessors may be used.

Whether software, firmware, hardware, or a combination is to be used,translation may be performed statically or dynamically. In fact, muchlike monitoring may be done dynamically during runtime or staticallybefore execution, translation and optimization may similarly beperformed. In the example where a compiler or user identifies hot region327, the optimization and translation may take place at that point(before execution). Here, a hot code identifier instruction may beutilized to both identify hot code region 327 and specify the locationof the optimized/translated code 304. However, no matter if section 327is identified as hot code before or during execution, the optimizationand translation, in some embodiments, takes place dynamically (duringruntime).

In one embodiment, hot region 327 is optimized/translated in parallelwith other execution. In one example, core 302 begins executingoptimization code in parallel with core 301's execution of region 327.Here, monitor module 305 detects execution of hot code region 327 oncore 301, so optimization is initiated on core 302. While furtherinstructions from hot region 327 are still being executed on core 301,core 302 begins optimization. As a result, core 302 is essentiallyoptimizing hot code 327 in parallel with execution of hot code 327 oncore 301. In another example, core 301 executes other sections ofprogram code 325 or other mutually exclusive code in parallel to core302's optimization of hot code 327. In another embodiment, optimizationof hot region 327 is done serially. For example, core 301 executes hotregion 327, and then subsequently core 301 or 302 optimizes hot coderegion 327.

In one embodiment, code 327 is stored at its original memory locationand translated on the fly by core 302. However, in most cases, it's moreefficient to translate/optimize an entire code section before execution.As a result, after optimization/translation module 310 optimizes codefor a core, such as core 302, the optimized hot code 304 is storedelsewhere. The other location for optimized hot code 304 may be anotherlocation in memory, such as a home, system memory location. Yet, sincehot code 327 is often associated with frequent execution, it'spotentially advantageous to hold optimized version 304 closer to core302. Therefore, in the illustrated embodiment, core 303 includes a codecache 303 to hold the optimized hot code 304. Note that code cache 303may be a separate cache structure in core 302; a shared cache structure,such as a shared instruction or data cache in core 302; or other generalstorage structure associated with core 302.

Referring back to the discussion of monitor module 305, one embodimentof encountering hot code region 327 includes a program counterreferencing an instruction address associated with a code section. Asdepicted, mapping module 315 is to hold a code region reference, such asthe instruction address, associated with optimized hot code reference317. Essentially, an entry of mapping module 315 associates hot coderegion 327 with an optimized version thereof (optimized hot code 304).As an illustrative example, reference 316 includes an address, such asthe instruction address, associated with hot region 327. In thisscenario, when core 301 encounters (a program counter points to) theinstruction address held in field 316 of mapping module 315, thenmonitor module 305 indicates that hot region 327 has been encounteredand is to be executed on core 302. Collaboration module 320, which isbriefly described above and discussed in more detail below, thenfacilitates the movement of data and/or context to core 302 forexecution.

Determining hot region 327 has been encountered and is to be executed oncore 302, in the above example, is only on reference 316. Theassociation of field 317 with field 316 may then be utilized to quicklydetermine where optimized hot code version 304 of region 327 is located.As a result, field 317 may include any reference to the location ofoptimized hot code 304. A few simple examples of such a referenceinclude: an address of an entry in code cache 303 holding optimized code304, an offset from the start of code cache 303 to entry 304 holdingoptimized hot code, and a physical or linear address associated withentry 304. Mapping module 315 is illustrated in a simple tablestructure, which may be implemented and/or maintained in hardware,software, firmware, or a combination thereof. Yet, any known method forassociating one location with another location may be utilized forassociating hot code 327 with an optimized version thereof.

Although not specifically illustrated, portions of monitor module 305 incombination with mapping module 315 may form a trigger module forindicating optimized hot code 304 is to be executed on core 302, insteadof native code 327 on core 301. As an example, when a program counterfor core 301 is moved to a next instruction address, trigger hardwarechecks that address against references stored in mapping hardware table315. Here, assume the program counter points the instruction addressthat references code region 327 held in field 316. Then, the triggerhardware, based on the entry in mapping table 315, indicates that anoptimized code region 304 for code region 327 exists. As a result,execution of code region 327 on core 301 may be elided, since anoptimized version already exists and is to be executed on core 302.

In one embodiment, core 301 halts execution (stops or transitions into alow power state) until core 302 completes execution of the optimizedcode. However, this may not take full advantage of the processingcapacity of processor 300. Therefore, in another embodiment, core 301interleaves execution of another software thread (code other thanprogram code 325), while optimized hot code 304 is executing on core302. As yet another example, core 301 may execute other portions ofprogram code 325 speculatively, which essentially performs a run-aheadhelper thread of execution, or executes other portions of code 325 thatdon't depend from code region 327 out-of-order.

Collaboration module 320, in one embodiment, provides collaborationfunctionality between cores 301, 302. As the simplest example,collaboration module 320 includes an interconnect between cores 301, 302to transfer information. Yet, in another embodiment collaboration moduleincludes other hardware, which may be exclusive to individual cores orshared between, to facilitate the aforementioned collaboration. Forexample, core 302 may share a shadow register file of core 301, suchthat a full context switch of register state from core 301 to core 302does not have to be performed when optimized hot code 304 is executed oncore 302. Instead, core 302 is able to directly access the shadowregister file in that scenario. However, collaboration module is notonly limited to shared structures and/or an interconnect. In fact,collaboration module 320 may include hardware, firmware, software, or acombination thereof to provide direct read and/or write access toregisters, storage structures, and buffers in both cores 301, 302. As aresult, collaboration module 320, in one embodiment, is capable oftransferring data/register values needed for execution of optimized hotcode from core 301 to core 302. And, it is also capable of transferringresults back from core 302 to core 301 to enable subsequent properexecution on core 301.

Although monitor module 305 has primarily been discussed in reference tomonitoring execution on native core 301, monitor module 305, in oneembodiment, is also to monitor execution of optimized code on core 302.As a result, monitor module 305 is capable of comparing performance ofcode section 327 on core 301 with performance of an optimized version304 on core 302. Furthermore, when performance on core 302 is lower thanperformance on core 301, or the performance gain is small on core 302 incomparison to an increase in power consumption, then the decision toidentify region 327 as hot code may be reversed. As an example, theentry of mapping module 315 indicating such a decision is de-allocatedor invalidated; such that the next time core 301 encounters hot code327, monitor module 305 does not detect reference 316 and does notindicate an optimized hot code version of region 327 should be executedon core 302. Essentially, the reversal sends the previously identifiedregion 327 back to out-of-order core 301.

As a specific illustrative example to further demonstrate thisperformance comparison, assume code region 327 is identified as hot codebased on a high-recurrence pattern and a high-instruction executioncount. As a result, code 327 is optimized by binary translation coderesident on core 302 to obtain optimized code 304. When optimized code304 is stored in code cache 303, an entry in mapping table 315 iscreated to associate code region 327 with optimized version 304. Whencore 301 next encounters a reference that matches the reference in field316, then execution of optimized code 304 is triggered on core 302,instead of executing code region 327 on core 301. Note thatcollaboration module through transfer, sharing, or context switchingprovides the proper values from core 301 to core 302. During core 302'sexecution of optimized hot code 304, the same performancemetric—instruction execution count—is tracked by monitor module 305. Ifthe instruction execution count is less than code region 327 wasexecuted on core 301, then the status quo of region 327 being identifiedas hot code continues in the future. However, if the instructionexecution count is longer on core 302 or a significant power increase isdetected, then the identification of region 327 as hot code may bereversed, as described above.

In addition to providing communication between cores 301 and 302,collaboration module 320 may also include other features to managemultiple cores of different types. As a first example, a power managerimplements a power algorithm to ensure both core 301 and 302 don'toperation at maximum power at the same time. However, this example ispurely illustrative. And other power algorithms may allow such maximumoperation. As another power consideration, core 302 may reside in apower state below maximum (a low-power state) during monitoring ofexecution on core 301. For example, when core 301 is associated withmechanisms to perform its own monitoring, then core 302 doesn't need tobe fully powered up until there is an optimized version of code to beexecuted. As a result, power is potentially saved by turning off core302 until it's needed for execution. Inversely, core 301 may be powereddown (put in a power state below maximum, such as an ACPI low powerstate or sleep state), while core 302 is executing optimized hot code.

Dynamically switching execution from core to core involves twochallenges: 1) timely and accurately predict the most appropriate corefor a given segment of code, and 2) efficiently migrate executionbetween cores.

In one embodiment, program execution on a first core may be identifiedby runtime software and/or hardware (e.g. based on analyzed ILP in thecode region), and then performance metrics and/or statistics of thecurrent core may be continuously collected by Monitor Module 305 topredict when the execution of program code should switch to a secondcore. This approach is highlighted in FIG. 4 . Since this approach usesdata from a single core to predict the other core's performance, in oneembodiment the approach is called a “single-core-prediction” algorithm.

Turning to FIG. 4 , an embodiment of a flow diagram for a method 400 ofdistributing code among a first core of a first type (such as anout-of-order core) and a second core of a second type (such as anin-order core) to achieve maximum performance and power savings isillustrated. Although the flows of FIG. 4 are illustrated in asubstantially serial fashion, the flows may be performed in a differentorder, as well as in parallel. Furthermore, each of the flows may beperformed utilizing hardware, firmware, or through execution of programcode.

Execution of program code on an out-of-order (OOO) processor core in aprocessor is monitored. Reference to program code, in one embodiment,refers to (1) execution of a compiler program(s), either dynamically orstatically, to compile other program code; (2) execution of a mainprogram, such as an operating system, hypervisor, application code, orother software program; (3) execution of other program code, such aslibraries, associated with the main program code, (4) execution of otherprogram code, such as helper threads or other tasks, which may not bedirectly associated with main program; or (5) a combination thereof.

A compiler often includes a program or set of programs to translatesource text/code into target text/code. Usually, compilation ofprogram/application code with a compiler is done in multiple phases andpasses to transform hi-level programming language code into low-levelmachine or assembly language code. Yet, single pass compilers may stillbe utilized for simple compilation. A compiler may utilize any knowncompilation techniques and perform any known compiler operations, suchas lexical analysis, preprocessing, parsing, semantic analysis, codegeneration, code transformation, and code optimization.

Larger compilers often include multiple phases, but most often thesephases are included within two general phases: (1) a front-end, i.e.,generally where syntactic processing, semantic processing, and sometransformation/optimization may take place, and (2) a back-end, i.e.,generally where analysis, transformations, optimizations, and codegeneration takes place. Some compilers refer to a middle end, whichillustrates the blurring of delineation between a front-end and back endof a compiler. As a result, reference to insertion, association,generation, or other operation of a compiler may take place in any ofthe aforementioned phases or passes, as well as any other known phasesor passes of a compiler.

In one embodiment, monitoring execution of program code by monitormodule 305 comprises tracking a number of times code segments/regionswithin the program code are executed. Code regions may be determined inany known manner of grouping instructions/code. As an example, each timean instruction address associated with a code section is referenced by aprogram counter of the OOO core, a recurrence count is incremented. Ifthe recurrence count for the code section exceeds a threshold, in oneembodiment, the code section is identified as hot code.

Either in conjunction with determining recurrence patterns orseparately, monitoring execution of program code may includedetermining/tracking a performance metric associated with code sections.As disclosed above, exemplary performance metrics may include:instruction retirement pushout, a number of instructions executed, anamount of time to execute a code region, a number of times a coderegions is encountered/executed, an amount of power consumed duringexecution of a code region, an amount of time spent in different powerstates during execution of a code region, and a thermal density duringexecution of a code segment. Yet, any known metric, or combination ofmetrics, associated with processor execution may be monitored duringexecution of the program code.

At block 402, program code may be executed on a first core. In anembodiment, the first core may be of a first type, such as a narrowout-of-order core. At block 404, performance of the first core may bemonitored as the first core executes the program code. At block 406,statistics on the performance may be collected. In an embodiment, thestatistics may include branch miss rate, cache miss rate, etc. In anembodiment, monitoring performance and collecting statistics may beperformed by Monitor Module 305. At block 408, the performance ofexecuting the program code on a second core may be predicted based atleast in part on the performance and statistics of executing the programcode on the first core. In an embodiment, the second code may be of asecond type, such as a wide in-order core. Alternatively, the first typemay be a wide in-order core and the second type may be a narrowout-of-order core. In an embodiment, the prediction may be implementedas a function called “predict_performance.” At block 410, if thepredicted performance of the second core to execute the program code isbetter than the monitored performance of the first core executing theprogram code, then the following actions may be performed.

At block 412, the second core may be powered up from a low power or“sleep” state. During the power up, the first core continues executionof the program. At block 414, execution of the program code may beswitched from the first core to the second core. At block 416, the firstcore may be powered down to a sleep state. If the predicted performanceof the second core is not better than the first core, execution of theprogram code on the first core may continue. In a subsequent iterationof the method, positions of the first core and the second core in themethod may be swapped (e.g., so that the second core is executed first,performance of the second core is monitored, statistics about the secondcore are collected, performance of the first core is predicted, and soon). In an embodiment, blocks 404 through 416 may be performed by CodeDistribution Module 210.

The function predict_performance (core number, performance_core1,statistics_core1) uses the current core execution performance andstatistics, performance_core1 and statistics_core1, to predict theperformance of the execution on the second core. If the predictedperformance is higher than that on the current core, the execution isswitched to the other core. This approach is based on the assumptionthat it is possible to predict the other core's performance using thecurrent core's performance information. Intuitively, a program executionwith excessive cache/branch misses should perform better on the narrowout-of-order core due to its ability to hide the miss latency byexecuting the later instructions out-of-order. On the other hand, aprogram with high instruction level parallelism (ILP) and lowcache/branch misses should run more efficiently on the wide-in-ordercore due to its high execution bandwidth.

In an embodiment, to define the function predict_performance, one mayfirst run n pieces of code, c1, . . . , cn, on both the first core andthe second core and collect their respective performance information(p11, p12, . . . , p1n), (p21, p22, . . . , p2n), and statistics (s11,s12, . . . , s1n), (s21, s22, . . . , s2n), on the two coresrespectively. Then one may find the best fit function F such that(F(p11,s11), F(p12,s12), . . . , F(p1n,s1n))−(p21, p22, . . . , p2n) and(F(p21,s21), F(p22,s22), . . . , F(p2n,s2n))−(p11, p12, . . . , p1n) isminimized. If the standard error of the best fit is small, one may use Fas the function predict_performance. If the standard error is high,however, one may need to find more performance parameters to enhance theprediction accuracy.

One advantage of this single-core-prediction approach is that it usesonly the current core execution statistics to predict the performance ofthe other core, without the performance and power overhead of involvingthe other core in making the decision. However, this approach assumesthat the performance of the two cores is closely correlated. In someenvironments/configurations, the performance of the two cores may beonly loosely correlated and a good fit function may not exist. Thereforeit may be desirable to have a more general approach.

In another embodiment, a dual-core-prediction process uses theperformance information observed on two cores in a short period topredict the core switch. Specifically, a “prediction” may be performedat regular intervals to sample and compare the performance on the twocores to decide whether or not to switch the execution to a differentcore. Note that each prediction may involve two core switches: the firstswitch takes place to get the performance information from the othercore, and the second switch may happen when the performance on the othercore is not as good as that on the first core so the execution shouldswitch back to the first core. The first core switch involves poweringup the other core and warming up its micro-architectural state forexecution, and the second switch only involves a core power-down.

To reduce core switch overhead, the prediction may be separated into twooperations: a “prediction for continuation” (Pcont) operation and a“prediction for switch” (Pswit). The Pcont operation compares theperformance information collected on the current core with the previousperformance information of the two cores to decide whether or not theexecution should continue on the current core. If the Pcont operationpredicts that the execution should not continue on the current core, thePswit operation activates the other core to run the other core for ashort time period and compare the performance information on the twocores to decide whether or not the execution should be switched to theother core. To prevent Pcont from continuing execution on the same corefor too long, the parameter K is introduced to dictate that the Pswitoperation cannot be skipped for more than K times in a row. Also, eachtime a Pswit operation is skipped, the previous performance is inflatedby an Inflation Factor so that the next Pcont period will find it harderto skip the Pswit operation.

The dual-core prediction process 500 is shown in FIG. 5 . In anembodiment, S is the sampling interval (e.g., number of cycles betweenpredictions), M is the sample length (e.g., in number of cycles) tocollect performance on each core, PU is a number of cycles for poweringup the second core, IPC is the number of instructions per cycle, K isthe maximum number of continuations (K being a natural number), N is thenumber of continuations (initially set to 0), and Prev_IPC is theprevious IPC (which may be initially set to MAX_FLOAT). In anembodiment, S, M, PU, K, and the Inflation Factor may be set toappropriate values.

At block 502, program code may be executed on the first core for asampling interval of S cycles. In an embodiment, the first core may beof a first type, such as a narrow out-of-order core. At block 504, powerup of the second core may be signaled PU cycles before the end of S+Mcycles from the start of program code execution. In an embodiment, thesecond core may be of a second type, such as a wide in-order core.Alternatively, the first type may be a wide in-order core and the secondtype may be a narrow out-of-order core. At block 506, the number ofinstructions per cycle for the first core (IPC1) may be collected for Mcycles. In an embodiment, monitoring performance and collectingstatistics may be performed by one of Monitor Module 305 or CodeDistribution Module 210.

Next, prediction for continuing execution on the first core (Pcont) maybe performed as follows. At block 508, if the number of continuations Nis less than the maximum number of continuations K, and the number ofinstructions per cycle for the first core IPC1 is greater than aprevious number of instructions per cycle (Prev_IPC, initially set to amaximum value), then blocks 510, 512, and 514 may be performed. In thiscase, a switch from the first core to the second core is not done. Atblock 510, power down of the second core may be signaled. At block 512,the previous number of instructions per cycle Prev_IPC may be set toPrev_IPC multiplied by the Inflation Factor. Processing continues withcontinued execution of the program code on the first core.

If the number of continuations N is less than or equal to the maximumnumber of continuations K, or the number of instructions per cycle forthe first core IPC1 is less than or equal to than a previous number ofinstructions per cycle Prev_IPC at block 508, then blocks 516, 518, and520 may be performed. In this case, a switch from the first core to thesecond core may be done. Next, prediction for switching execution(Pswit) from the first core to the second core may be performed asfollows. At block 516, counter N may be set to 0. At block 518,execution of the program code may be switched from the first core to thesecond core and the number of instructions per cycle for the second core(IPC2) may be collected. Next, a check is made to verify that the switchwas worthwhile.

At block 520, if the number of instructions per cycle on the second core(IPC2) is less than the number of instructions per cycle on the firstcore (IPC1), then execution of the program code may be switched from thesecond core back to the first core at block 522. Alternatively, ifanother performance metric is used other than number of instructions percycle, then if performance on the second core is not better thanperformance on the first core, then execution of the program code may beswitched from the second core back to the first core. Power down of thesecond core may then be signaled at block 524. However, if at block 520the number of instructions per cycle on the second core (IPC2) is notless than the number of instructions per cycle on the first core (IPC1),then the switching of cores is worthwhile. Alternatively, if anotherperformance metric is used other than number of instructions per cycle,then if performance on the second core is better than or equal toperformance on the first core, then switching of cores is worthwhile. Atblock 528, power down of the first core may be signaled. In either case,processing continues in one embodiment at block 530 with a setting ofthe previous number of instructions per cycle (Prev_IPC) to the averageof the IPC values (e.g., IPC1+IPC2/2). Although we use arithmetic meanas the average here, we can also use geometric mean, harmonic mean, andany other means to present the average of the two IPC values. Processingis now performed on the second core with the first core being powereddown. In a subsequent iteration of the method, positions of the firstcore and the second core in the method may be swapped (e.g., so thesecond core is executed first for S cycle, signal power up of the firstcore, performance of the second core is monitored for M cycles,statistics about the second core are collected, and so on). In anembodiment, at least blocks 504 through 530 may be performed by CodeDistribution Module 210.

Core switching involves several overheads: 1) activating the other corewhich may be in a low power state; 2) transferring x86 register statesto the other core; 3) moving frequently accessed data into the otherdata cache; and 4) warming up instruction cache, branch predictor state,and other states on the other core.

The latency to wake up (or power up) the other core depends on the lowpower state in which the other core is in. In some embodiments, if thecore is in the low power C2 state, which consumes .about.30% of regularoperating power, it may take .about.5000 cycles to power the core up tonormal operating speed (CO state). If the core is in deeper power-downstate (C6), which consumes <10% of operating power, it can take.about.200K cycles to wake up in one embodiment. Although the power-uptakes time, it can be done in parallel with the execution on the othercore. For example, in an embodiment before the first core enters thePswit/Pcont period, the first core (or other module) can send a signalto the second core to initiate power-up. At the end of the first core'sprediction period, the second core may be already powered up and cancontinue execution of the program code. With this early power-upstrategy, power-up latency should affect neither the core switch latencynor the performance, although it increases energy consumption.

In an embodiment, data and instruction caches may take up to 10K cyclesto warm-up, even if the level 2 (L2) cache is shared among the twocores. Also, modern hybrid branch predictors allow the branch predictorto be warmed up fairly quickly. Assume the core power up takes PU cyclesand the branch predictor and L1 cache warm-up takes WU cycles. FIG. 6illustrates the core switching action and overhead. The representationsof time in FIG. 6 are merely illustrative and are not meant to conveyany actual, specific timing relationships between the various stages.Before the first core 601 enters the Pcont period, the first coresignals the second core 602 to power-up 603. After the first corefinishes its Pcont operation and finds that a core switch may be needed,program code execution may be switched to the second core 604. At thattime, the second core has already been powered up, and starts itswarm-up for WU cycles 605. After the warm-up period, the second coreruns for a short time (e.g., M cycles) to collect its performance data606. Let's assume that at that time the second core's performance isbetter than the first core's performance, so the second core signals thefirst core to power down (PD) 607, and continues execution on the secondcore. Near the end of the next Pcont period, the second core signals tothe first core to power-up 608. After the second core finishes its Pcontperiod and finds that the second core should continue execution, thesecond core signals the first core to power-down 609 and continuesexecution of the program code on the second core.

As a result of coupling a native core with a different co-designed core,the best of power and execution benefits are potentially obtained evenwithin a single application when using dynamic core selection techniquesas discussed herein. For example, with an out-of-order core and asoftware managed, in-order core, code that is not efficient on thesoftware-managed core is migrated to the out-of-order core. Andinversely, the code that is not efficient on the out-of-order core ismigrated to the software managed core. Through hardware, software,firmware, or a combination therefore parallel execution of native code,hot code detecting, and hot code optimization may be efficientlymanaged, while individual sections of multiple threads may beefficiently interleaved in a pipelined fashion between the out-of-orderand in-order co-designed cores. As a result, maximum performance may beobtained, while achieving better power performance through differentpower efficiency techniques, such as placing the out-of-order core in alow power state during execution on the in-order core in someimplementations.

A module as used herein refers to any hardware, software, firmware, or acombination thereof. Often module boundaries that are illustrated asseparate commonly vary and potentially overlap. For example, a first anda second module may share hardware, software, firmware, or a combinationthereof, while potentially retaining some independent hardware,software, or firmware. In one embodiment, use of the term logic includeshardware, such as transistors, registers, or other hardware, such asprogrammable logic devices. However, in another embodiment, logic alsoincludes software or code integrated with hardware, such as firmware ormicro-code.

A value, as used herein, includes any known representation of a number,a state, a logical state, or a binary logical state. Often, the use oflogic levels, logic values, or logical values is also referred to as 1'sand 0's, which simply represents binary logic states. For example, a 1refers to a high logic level and 0 refers to a low logic level. In oneembodiment, a storage cell, such as a transistor or flash cell, may becapable of holding a single logical value or multiple logical values.However, other representations of values in computer systems have beenused. For example the decimal number ten may also be represented as abinary value of 1010 and a hexadecimal letter A. Therefore, a valueincludes any representation of information capable of being held in acomputer system.

Moreover, states may be represented by values or portions of values. Asan example, a first value, such as a logical one, may represent adefault or initial state, while a second value, such as a logical zero,may represent a non-default state. In addition, the terms reset and set,in one embodiment, refer to a default and an updated value or state,respectively. For example, a default value potentially includes a highlogical value, i.e. reset, while an updated value potentially includes alow logical value, i.e. set. Note that any combination of values may beutilized to represent any number of states.

The embodiments of methods, hardware, software, firmware or code setforth above may be implemented via instructions or code stored on amachine readable medium which are executable by a processing element. Amachine-readable medium includes any mechanism that provides (i.e.,stores and/or transmits) information in a form readable by a machine,such as a computer or electronic system. For example, a machine-readablemedium includes random-access memory (RAM), such as static RAM (SRAM) ordynamic RAM (DRAM); ROM; magnetic or optical storage medium; flashmemory devices; electrical storage devices; optical storage devices;etc.

Reference throughout this specification to “one embodiment” or “anembodiment” means that a particular feature, structure, orcharacteristic described in connection with the embodiment is includedin at least one embodiment of the present invention. Thus, theappearances of the phrases “in one embodiment” or “in an embodiment” invarious places throughout this specification are not necessarily allreferring to the same embodiment. Furthermore, the particular features,structures, or characteristics may be combined in any suitable manner inone or more embodiments.

In the foregoing specification, a detailed description has been givenwith reference to specific exemplary embodiments. It will, however, beevident that various modifications and changes may be made theretowithout departing from the broader spirit and scope of the invention asset forth in the appended claims. The specification and drawings are,accordingly, to be regarded in an illustrative sense rather than arestrictive sense. Furthermore, the foregoing use of embodiment andother exemplarily language does not necessarily refer to the sameembodiment or the same example, but may refer to different and distinctembodiments, as well as potentially the same embodiment.

The invention claimed is:
 1. A multi-core computer system comprising: afirst processor core of a first type; a second processor core of asecond type different from the first type; and software to: access auser-supplied hint indicative of a user preference to execute programcode on the first processor core, the user-supplied hint including auser-defined attribute of the program code; monitor performance of theprogram code on the first processor core; determine, based on theuser-defined attribute of the program code, a predicted performance ofthe program code on the second processor core is better than theperformance of the program code on the first processor core; and ignorethe user preference by migrating the program code from the firstprocessor core for execution on the second processor core.
 2. Themulti-core computer system of claim 1, wherein the software is todetermine the predicted performance of the program code on the secondprocessor core is better than the performance of the program code on thefirst processor core by profiling the program code to generate theuser-supplied hint.
 3. The multi-core computer system of claim 1,wherein the software is further to: monitor, subsequent to the migrationof execution of the program code to the second processor core,performance of the execution of the program code by the second processorcore; determine, based on the performance of execution of the programcode on the second processor core and the user-supplied hint, whetherthe performance of the program code by the first processor core isbetter than the performance of the program code on the second processorcore; and migrate execution of the program code from the secondprocessor core back to the first processor core in response to adetermination that the performance of the program code on the firstprocessor core is better than the performance of the program code on thesecond processor core.
 4. The multi-core computer system of claim 1,wherein the first processor core is an in-order processor core and thesecond processor core is an out-of-order processor core.
 5. Themulti-core computer system of claim 1, wherein the second processor coreis an in-order processor core and the first processor core is anout-of-order processor core.
 6. The multi-core computer system of claim1, wherein the software is further to power up the second processor corein response to the determination that the predicted performance of theprogram code on the second processor core is better than the monitoredperformance of the program code on the first processor core.
 7. Themulti-core computer system of claim 1, wherein the software is furtherto power down the first processor core in response to the migration ofexecution of the program code from the first processor core to thesecond processor core.
 8. At least one computer readable storage disk orstorage device comprising instructions which, when executed, cause oneor more processors to at least: access a user-supplied hint indicativeof a user preference to execute program code on a first processor coreof a first type, the user-supplied hint including a user-definedattribute of the program code; monitor performance of the program codeon the first processor core; determine, based on the user-definedattribute of the program code, a predicted performance of the programcode on a second processor core is better than the performance of theprogram code on the first processor core, the second processor core of asecond type different than the first type; and ignore the userpreference by migrating the program code from the first processor corefor execution on the second processor core.
 9. The at least one computerreadable storage disk or storage device of claim 8, wherein theinstructions cause the one or more processors to determine the predictedperformance of the program code on the second processor core is betterthan the performance of the program code on the first processor core byprofiling the program code to generate the user-supplied hint.
 10. Theat least one computer readable storage disk or storage device of claim8, wherein the instructions cause the one or more processors to:monitor, subsequent to the migration of execution of the program code tothe second processor core, performance of the execution of the programcode by the second processor core; determine, based on the performanceof execution of the program code on the second processor core and theuser-supplied hint, whether the performance of the program code by thefirst processor core is better than the performance of the program codeon the second processor core; and migrate execution of the program codefrom the second processor core back to the first processor core inresponse to a determination that the performance of the program code onthe first processor core is better than the performance of the programcode on the second processor core.
 11. The at least one computerreadable storage disk or storage device of claim 8, wherein the firstprocessor core is an in-order processor core and the second processorcore is an out-of-order processor core.
 12. The at least one computerreadable storage disk or storage device of claim 8, wherein the secondprocessor core is an in-order processor core and the first processorcore is an out-of-order processor core.
 13. The at least one computerreadable storage disk or storage device of claim 8, wherein theinstructions cause the one or more processors to power up the secondprocessor core in response to the determination that the predictedperformance of the program code on the second processor core is betterthan the monitored performance of the program code on the firstprocessor core.
 14. The at least one computer readable storage disk orstorage device of claim 8, wherein the instructions cause the one ormore processors to power down the first processor core in response tothe migration of execution of the program code from the first processorcore to the second processor core.
 15. An apparatus comprising: a firstprocessor core of a first type; a second processor core of a second typedifferent from the first type; instructions; and processor circuitry toexecute the instructions to: access a user-supplied hint indicative of auser preference to execute program code on the first processor core ofthe first type, the user-supplied hint including a user-definedattribute of the program code; monitor a first performance of theprogram code on the first processor core; predict a second performanceof the program code on the second processor core; determine, based onthe user-defined attribute of the program code, that the secondperformance of the program code on the second processor core is betterthan the first performance of the program code on the first processorcore; and ignore the user preference by migrating the program code fromthe first processor core for execution on the second processor core. 16.The apparatus of claim 15, wherein the processor circuitry is todetermine the second performance of the program code on the secondprocessor core is better than the first performance of the program codeon the first processor core by profiling the program code to generatethe user-supplied hint.
 17. The apparatus of claim 15, wherein theprocessor circuitry is further to: monitor, subsequent to the migrationof execution of the program code to the second processor core, thirdperformance of the execution of the program code by the second processorcore; determine, based on the third performance of execution of theprogram code on the second processor core and the user-supplied hint,whether fourth performance of the program code by the first processorcore is better than the third performance of the program code on thesecond processor core; and migrate execution of the program code fromthe second processor core back to the first processor core in responseto a determination that the fourth performance of the program code onthe first processor core is better than the third performance of theprogram code on the second processor core.
 18. The apparatus of claim15, wherein the first processor core is an in-order processor core andthe second processor core is an out-of-order processor core.
 19. Theapparatus of claim 15, wherein the second processor core is an in-orderprocessor core and the first processor core is an out-of-order processorcore.
 20. The apparatus of claim 15, wherein the processor circuitry isfurther to power up the second processor core in response to thedetermination that the second performance of the program code on thesecond processor core is better than the first performance of theprogram code on the first processor core.